/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

/**
 *
 * @author usfch
 */
public class Connect extends Thread {
    
    private String Nomserver;
    private int port;

    public void setNomserver(String Nomserver) {
        this.Nomserver = Nomserver;
    }

    public void setPort(String port) {
        
        this.port =Integer.parseInt(port);
    }

    
    PrintWriter out = null;
    BufferedReader in = null;

    public Connect() {
    }

    public void run() {


        Socket clientSocket;

        try {
            //establish connection
            System.out.println("inside run");

            clientSocket = new Socket(Nomserver, port);
            System.out.println(clientSocket.toString());
            //use this connection
            /*
            byte[] mybytearray = new byte[(int) myFile.length()];
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(myFile));
            bis.read(mybytearray, 0, mybytearray.length);
            OutputStream os = clientSocket.getOutputStream();
           os.write(mybytearray, 0, mybytearray.length);
             * 
             */
            
            

        } catch (IOException ex) {
            System.out.println("Accept failed: 1234");
            System.out.println(ex.getMessage());
            System.exit(-1);
        }
    }
}
